﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace PRE.Thongke_Baocao
{
    public partial class FrmSPSXcuaDNtrongkhoangti_hoigian : DevExpress.XtraEditors.XtraForm
    {
        DAL.ThongKeBaoCaoDAL _dal = new DAL.ThongKeBaoCaoDAL();
        BLL.ThongKeBaoCaoBLL _bll = new BLL.ThongKeBaoCaoBLL();
        public FrmSPSXcuaDNtrongkhoangti_hoigian()
        {
            InitializeComponent();
        }

   
        private void btthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmSPSXcuaDNtrongkhoangti_hoigian_Load(object sender, EventArgs e)
        {
            cbodn.Properties.DataSource = _dal.select_DN();
            cbodn.ItemIndex = 0;
            dtebd.EditValue = _bll.GetDate();
            dtekt.EditValue = _bll.GetDate();
        }

        private void btxem_Click(object sender, EventArgs e)
        {
            string id = (cbodn.EditValue + "").Trim();
            DateTime bd = Convert.ToDateTime(dtebd.EditValue);
            DateTime kt = Convert.ToDateTime(dtekt.EditValue);
            DataTable _dtb= _dal.select_thongkeSP_SX(id, bd, kt);
            grcMain.DataSource = _dtb;
            txttendn.DataBindings.Clear();
            txtmadn.DataBindings.Clear();
            txtdc.DataBindings.Clear();
            txtsdt.DataBindings.Clear();
            txtfax.DataBindings.Clear();
            txtmalv.DataBindings.Clear();
            txttenlv.DataBindings.Clear();

            txtmadn.DataBindings.Add("EditValue", _dtb, ".MSDN");
            txttendn.DataBindings.Add("EditValue", _dtb, ".TENDN");
            txtdc.DataBindings.Add("EditValue", _dtb, ".DC");
            txtsdt.DataBindings.Add("EditValue", _dtb, ".DT");
            txtfax.DataBindings.Add("EditValue", _dtb, ".FAX");
            txtmalv.DataBindings.Add("EditValue", _dtb, ".MSLVDN");
            txttenlv.DataBindings.Add("EditValue", _dtb, ".TENLVDN");
        }

        private void btin_Click(object sender, EventArgs e)
        {
            string id = (cbodn.EditValue + "").Trim();
            DateTime bd = Convert.ToDateTime(dtebd.EditValue);
            DateTime kt = Convert.ToDateTime(dtekt.EditValue);
            DataTable _dtb = _dal.select_thongkeSP_SX(id, bd, kt);

            var frm = new Report.Report_Base();
            var xr = new Report.XRSanPhamSuanXuat();
            xr.ngaybd = bd;
            xr.ngaykt = kt;
            xr.DataSource = _dtb;
            frm.SetReport(xr);

            frm.Show();
        }
        
    }
}